package com.solution.wx.order.config;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.github.wxpay.sdk.WXPayConfig;

public class WxpayConfig implements WXPayConfig{
	
	private byte[] certData;
	private static WxpayConfig INSTANCE;

    private WxpayConfig() throws Exception{
    	/**
    	微信支付证书路径
        String certPath = "D://CERT/common/apiclient_cert.p12";
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    	*/
    }

    public static WxpayConfig getInstance() throws Exception{
        if (INSTANCE == null) {
            synchronized (WxpayConfig.class) {
                if (INSTANCE == null) {
                    INSTANCE = new WxpayConfig();
                }
            }
        }
        return INSTANCE;
    }

	@Override
	public String getAppID() {
        return "wx80262f273825e6cd";
	}

	@Override
	public String getKey() {
		return "44be14e85d034bf1a3a5caa47c5532c7";
	}

	@Override
	public String getMchID() {
		return "1488545602";
	}

	@Override
	public InputStream getCertStream() {
		ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
		return certBis;
	}

	@Override
	public int getHttpConnectTimeoutMs() {
        return 2000;
	}

	@Override
	public int getHttpReadTimeoutMs() {
        return 10000;
	}
	
	public String getNotifyUrl() {
		return "https://admin.jxdol.com/wx/wxpay/wxpayNotify";
	}
	
	public String getSpbillCreateIp() {
		return "47.96.20.34";
	}
}
